<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<fmt:setBundle basename="ApplicationResources" />
<title>Maintain User</title>
</head>
<body>
	<form action="${pageContext.request.contextPath}/controller/setupuser"
		method=post>
		<center>
			<table cellpadding=4 cellspacing=2 border=0>
				<tr>
					<th width="30%"><fmt:message key="label.cruduser.maintain" /></th>
					<th width="45%"></th>

				</tr>
				<tr>
					<td><c:if test="${param['insert'] == 'true'}">
							<!-- 	<input type="text" name="name" value="${param['program_id']}" size=15
								maxlength=20>  -->
							<input type="hidden" name="ins" value="true" />
						</c:if> 
						<c:if test="${param['insert']=='false'}">
							<!-- 	<input type="text" name="program_id" value="${param['program_id']}" size=15
								maxlength=20 readonly="readonly"> -->
							<input type="hidden" name="user_id" value="${param['user_id']}" />
							<input type="hidden" name="ins" value="false" />
						</c:if>
						<input type="hidden" name="ins" value="false" />
						<input type="hidden" name="id" value="${edituser.id}" />
						
						</td>
				</tr>
				<tr>
					<td><fmt:message key="label.cruduser.name" /></td>
					<td><input type="text" name="name" value="${edituser.name}" required="true"
						size=45 maxlength=20> <font color="red">*</font></td>
				</tr>
				<tr>
					<td><fmt:message key="label.cruduser.firstName" /></td>
					<td><input type="text" name="firstName" required
						value="${edituser.firstName}" size=15 maxlength=20> <font color="red">*</font></td>
				</tr>

				<tr>
					<td><fmt:message key="label.cruduser.lastName" /></td>
					<td><input type="text" name="lastName" required
						value="${edituser.lastName}" size=15 maxlength=20> <font color="red">*</font></td>
				</tr>
				
				<tr>
					<td><fmt:message key="label.cruduser.password" /></td>
					<td><input type="password" name="password" required
						value="${edituser.password}" size=15 maxlength=20><font color="red">*</font></td>
				</tr>
				
				<tr>
					<td><fmt:message key="label.cruduser.role" /></td>
					<td>
					<select multiple="multiple" name="roles" required> <font color="red">*</font>
							<c:forEach var="role" items="${allroles}" varStatus="status">
							<c:set var="selected" value="0"/>
								<c:forEach var="userrole" items="${userroles}" varStatus="status">
								   <c:if test="${userrole.roleId==role.roleId}">
									   <c:set var="selected" value="1"/>
									 </c:if>
								</c:forEach>
							
							<c:if test='${selected=="1"}'>
									   <option value="${role.roleId}" selected> ${role.roleName}</option>
									 </c:if>
						 <c:if test='${selected=="0"}'>
									   <option value="${role.roleId}"> ${role.roleName}</option>
							 </c:if>
							 
							</c:forEach>
						</select>
						</td>
				</tr>
			</table>
		</center>
		<input type="submit" value="Submit"> <input type="reset"
			value="Reset">
	</form>


</body>
</html>